<?php
/*
+ --------------------------------------------------- +
|  Ineo Article Manager - Version 1.x
|  Copyright 2006-2007, Dan Cryer and William McGann
+ --------------------------------------------------- +

Ineo Article Manager is free software; you can redistribute it and/or modify
it under the terms of version 3 of the GNU General Public License as published by
the Free Software Foundation.

Ineo Article Manager is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with Ineo; see the file License.txt.  If not, write to
the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.

*/

/**
* Upgrade - MySQL Updates
*/
class upgrade_database
{
	var $refresh_after_step = true;
	var $await_input        = false;

	function upgrade_database( &$installer )
	{
		$this->installer =& $installer;
		$this->ipsclass  =& $installer->ipsclass;
	}

	function run_step()
	{
		$_queries = array();
		
		foreach( $this->installer->packs as $pack )
		{
			unset($queries);
			
			$sql_updates = $this->installer->data_dir.$pack.'/'.$this->installer->ipsclass->vars['sql_driver'].'_updates.php';
			
			if( file_exists($sql_updates) )
			{
				require_once($sql_updates);
			}
			
			$_queries = array_merge($_queries, $queries);
		}
		
		foreach( $_queries as $query )
		{
			$this->installer->ipsclass->DB->query($query);
		}
		
		$this->installer->status_text .= count($_queries) . ' queries run.';
	}
}

?>